using System;
using System.Runtime.Serialization;

namespace RomanJendrusz.Amazon.ETL.Exceptions
{
    public class InvalidResponseCastException: InvalidCastException
    {
        private readonly Type ofOrginalResponse;
        private readonly Type ofCastedResponse;

        public InvalidResponseCastException(Type ofOrginalResponse, Type ofCastedResponse ,string message) : base(message)
        {
            this.ofOrginalResponse = ofOrginalResponse;
            this.ofCastedResponse = ofCastedResponse;
        }

        public InvalidResponseCastException(Type ofOrginalResponse, Type ofCastedResponse)
        {
            this.ofOrginalResponse = ofOrginalResponse;
            this.ofCastedResponse = ofCastedResponse;
        }

        public InvalidResponseCastException(Type ofOrginalResponse, Type ofCastedResponse,string message, Exception innerException) : base(message, innerException)
        {
            this.ofOrginalResponse = ofOrginalResponse;
            this.ofCastedResponse = ofCastedResponse;
        }

        public InvalidResponseCastException(Type ofOrginalResponse, Type ofCastedResponse, string message, int errorCode) : base(message, errorCode)
        {
            this.ofOrginalResponse = ofOrginalResponse;
            this.ofCastedResponse = ofCastedResponse;
        }

        public InvalidResponseCastException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }

        public override string Message
        {
            get
            {
                return base.Message + "\r\nExpected Type: " + ofCastedResponse.FullName + "\r\nbut was: " + ofOrginalResponse.FullName ;
            }
        }
    }
}